const network = require('../../utils/network.js')
const loginUtil = require('../../utils/login.js')

const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:{
      models:[]
    },
    order: {
      name: '我的订单',
      desc: '',
      icon: '../../assets/images/me/order.png',
      page: '../order/order-list'
    },
    coins: {
      name: '我的M币',
      desc: '',
      icon: '../../assets/images/me/jifen.png',
      page: '../me/myIntegral'
    },
    yuyue: {
      name: '我的预约',
      desc: '',
      icon: '../../assets/images/me/suishendai.png',
      page: '../dev/develop-page'
    },
    points: {
      name: '积分商城',
      desc: '',
      icon: '../../assets/images/me/jifen.png',
      page: '../me/mybook-list'
    },
    message: {
      name: '消息中心',
      desc: '',
      icon: '../../assets/images/me/interactive_fill.png',
      page: '../dev/develop-page'
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  itemClick: function (e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.page,
    })
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const loginInfo = loginUtil.loadLoginInfo();
    network.getRequest('mp/service/user/info', 'accesstoken=' + loginInfo.accessToken,(res)=>{
      app.globalData.userInfo = res.data;
      this.setData({
        userInfo:res.data
      })
    },err=>{
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

// 积分充值
  coinCharge:function(){
    wx.navigateTo({
      url: '/pages/charge/coin-charge',
    })
  },

  goProfile:function(){
    wx.navigateTo({
      url: '/pages/me/profile',
    })
  },

  login:function(){
    wx.navigateTo({
      url: '/pages/login/Login',
    })
  }
})